<#assign module="errand"/>

<@override name="header">
</@override>
<@override name="body">

<div class="tabbable tabs-left">
	<div class="row">
		<div class="col-xs-12">
			<div class="orders-navt">
				<ul class="orders-nav">
	                <@shiro.hasPermission name='errand'>
	                	<li><a href="${ctx}/errand/orderType">类型</a></li>
	                </@shiro.hasPermission>
	                <@shiro.hasPermission name='errandSet'>
	                	<li class="orders-click"><a  href="${ctx}/errand/feelist" class="orders-click-a">收费</a></li>
	                </@shiro.hasPermission>
	            </ul>
	    	</div>
	    	<div class="orders-navh">
		       <a href="${ctx}/errand/newfee" class="pull-right btn btn-primary"><i class="icon-plus"></i>&nbsp;新增收费内容</a>
			</div>
		</div>
	</div>
</div>
<div><span style="color:red;font-size:17px;">此费用设置只用于客户端时显示，不作为计算订单费用使用，实际订单费用请设置系统的收费标准</span></div>
<div class="row margin-top area_container">
	<#if feelist??>
  		<#list feelist as fee>
			<form action="${ctx}/" class="form-horizontal" method="post">
				<input type="hidden" name="id" value="">
				<div class="col-md-12">
					<div class="panel panel-default">
					  <div class="panel-heading">
					  	<#if fee_index==0>
			            	<span>默认</span>
			          	<#else>
			          		<span>${fee.name?if_exists} - ${fee.acKey?if_exists}</span>
			            	<button data-value="${fee.id}" type="button" class="delete-fee pull-right button button-pill button-flat-caution button-tiny"><span class="glyphicon glyphicon-remove"></span>&nbsp;删除</button>
			          	</#if>
			          </div>
					  <div class="panel-body">
					  
						<#if fee.list??>
							<#list fee.list as city>
								<div class="btn-group">
								  <a class="btn btn-default" href="${ctx}/errand/editfeecontent/${city.id}" target="_blank">${city.city?if_exists}</a>
								  <a class="btn btn-primary delete-fee-content" data-value="${city.id}">删除</a>
								</div>
							</#list>
						</#if>
						
		  				<div id="add-city-button-1" class="btn-group" style="margin-left:10px;">
						  <a class="btn btn-primary" href="${ctx}/errand/newfeecontent/${fee.id}" target="_blank"><i class="icon-plus"></i></a>
						</div>
						
					  </div>
					</div>
				</div>
			</form>
			
  		</#list>
  	</#if>
	
</div>


</@override>
<@override name="footer">

<script type="text/javascript">
    var thisButton;
	function deleteFee() {
	    $.post('${ctx}/errand/deleteFee',{'id':thisButton.attr("data-value")},function(data){
            if(data.success){
            	$.scojs_message('删除成功', $.scojs_message.TYPE_OK);
	            setTimeout(function(){
	            	window.location.reload(true);
	            }, 1000);
            } else {
                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
            }
	    },'json');
	}
	
	function deleteFeeContent() {
	    $.post('${ctx}/errand/deleteFeeContent',{'id':thisButton.attr("data-value")},function(data){
            if(data.success){
            	$.scojs_message('删除成功', $.scojs_message.TYPE_OK);
	            setTimeout(function(){
	            	window.location.reload(true);
	            }, 1000);
            } else {
                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
            }
	    },'json');
	}
	
	
    $(document).ready(function(){
	    $(".delete-fee").click(function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
	            content: "你确认要删除该收费内容吗？",
	            action:deleteFee
	          });
	          confirm.show();
	    });
	    
	    $(".delete-fee-content").click(function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
	            content: "你确认要删除该城市？",
	            action:deleteFeeContent
	          });
	          confirm.show();
	    });
	    
	});
    
</script>
</@override>
<@extends name="../layout.ftl"/>